home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / inet / internet-drafts / draft-ietf-cat-ftpsec-02.txt < prev    next >
Text File  |  1993-07-08  |  38KB  |  929 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7. Network Working Group                    Internet Engineering Task Force
  8. Internet-Draft            Common Authentication Technology Working Group
  9. Updates: RFC 959                                              S. J. Lunt
  10.                                                                 Bellcore
  11.                                                                July 1993
  12.  
  13.  
  14.                         FTP Security Extensions
  15.  
  16. Status of this Memo
  17.  
  18.    This document is an Internet  Draft.   Internet  Drafts  are  working
  19.    documents  of  the Internet Engineering Task Force (IETF), its Areas,
  20.    and its Working Groups. Note that other groups  may  also  distribute
  21.    working documents as Internet Drafts.
  22.  
  23.    Internet Drafts are draft  documents  valid  for  a  maximum  of  six
  24.    months. Internet  Drafts  may  be  updated, replaced, or obsoleted by
  25.    other documents at any time.  It is not appropriate to  use  Internet
  26.    Drafts as reference material or to cite them other than as a "working
  27.    draft" or "work in progress."
  28.  
  29.    Please check the I-D abstract  listing  contained  in  each  Internet
  30.    Draft  directory  to  learn  the  current status of this or any other
  31.    Internet Draft.
  32.  
  33.    Distribution of this memo is unlimited.  Please send comments to  the
  34.    <ftp-wg@tgv.com> mailing list.
  35.  
  36. 1. Description
  37.  
  38.    This document defines extensions to the FTP  specification  RFC  959,
  39.    "FILE  TRANSFER  PROTOCOL (FTP)" (October 1985), which provide strong
  40.    authentication, integrity, and confidentiality on  both  the  control
  41.    and  data  channels  with  the introduction of new optional commands,
  42.    replies, and file transfer encodings.
  43.  
  44.    The  following  new  optional  commands  are   introduced   in   this
  45.    specification:
  46.  
  47.       AUTH  (Authentication  Type),  ADAT  (Authentication  Data),   MIC
  48.       (Integrity  Protected  Command),  ENC (Privacy Protected Command),
  49.       and PROT (Data Channel Protection Level).
  50.  
  51.    A new class of reply types (6yz) is  also  introduced  for  protected
  52.    replies.
  53.  
  54.  
  55.  
  56.  
  57. Expires: January 31, 1994                                       [Page 1]
  58.  
  59. Internet-Draft          FTP Security Extensions                July 1993
  60.  
  61.  
  62.    None of the above commands are required to be implemented,  but  each
  63.    is dependent on the other (except ENC, which is optional).
  64.  
  65.    Note that this specification is compatible with RFC 959.
  66.  
  67. 2. Motivation
  68.  
  69.    The File Transfer Protocol (FTP) currently defined in RFC 959 and  in
  70.    place  on  the  Internet  uses  usernames  and  passwords  passed  in
  71.    cleartext to authenticate clients to servers (via the USER  and  PASS
  72.    commands).   Except  for  services  such as 'anonymous' FTP archives,
  73.    this represents a security  risk  whereby  passwords  can  be  stolen
  74.    through monitoring of local and wide-area networks.  This either aids
  75.    potential  attackers  through   password   exposure   and/or   limits
  76.    accessibility of files to remote users who can or will not accept the
  77.    inherent security risk.
  78.  
  79.    Aside from the problem of authenticating users in  a  secure  manner,
  80.    there  is  also  the  problem  of  protecting  sensitive  data and/or
  81.    verifying its integrity.  An attacker may be able to access  valuable
  82.    or  sensitive  data merely by monitoring a network, or through active
  83.    means may be able to delete or modify the data being  transferred  so
  84.    as  to  corrupt  its integrity.  An active attacker may also initiate
  85.    spurious file transfers to and from a site of the attacker's  choice,
  86.    and  may invoke other commands on the server.  FTP does not currently
  87.    have  any  provision  for  the  encryption  or  verification  of  the
  88.    authenticity  of  commands,  replies, or transferred data.  Note that
  89.    these security services have value even to anonymous file access.
  90.  
  91.    Current practice for sending files securely is generally either:
  92.  
  93.  
  94.      1.  via FTP of files pre-encrypted under keys  which  are  manually
  95.          distributed,
  96.  
  97.      2.  via electronic mail containing an encoding of a file  encrypted
  98.          under keys which are manually distributed,
  99.  
  100.      3.  via a PEM message, or
  101.  
  102.      4.  via the rcp command enhanced to use Kerberos.
  103.  
  104.  
  105.    None of these means could be considered even a de facto standard, and
  106.    none are truly interactive.  A need exists to securely transfer files
  107.    using FTP in a secure  manner  which  is  supported  within  the  FTP
  108.    protocol in a consistent manner and which takes advantage of existing
  109.    security infrastructure and technology.  Extensions are necessary  to
  110.    the FTP specification if these security services are to be introduced
  111.    into the protocol in an interoperable way.
  112.  
  113.  
  114.  
  115. Expires: January 31, 1994                                       [Page 2]
  116.  
  117. Internet-Draft          FTP Security Extensions                July 1993
  118.  
  119.  
  120.    Although the FTP control connection follows the Telnet protocol,  and
  121.    Telnet  has  defined an authentication and encryption option [5], RFC
  122.    1123 [4] explicitly forbids the use of Telnet option negotiation over
  123.    the  control  connection (other than Synch and IP).  Also, the Telnet
  124.    authentication and encryption option does not provide  for  integrity
  125.    protection  only  (without confidentiality), and does not address the
  126.    protection of the data channel.
  127.  
  128. 3. New FTP Commands
  129.  
  130.    The following commands are optional, but  dependent  on  each  other.
  131.    They are extensions to the FTP Access Control Commands.
  132.  
  133.    AUTHENTICATION TYPE (AUTH)
  134.  
  135.       The argument field is a  Telnet  string  identifying  a  supported
  136.       authentication  mechanism.   The  command  represents a request to
  137.       perform  an  authentication  protocol   exchange   based   on   an
  138.       authentication  mechanism  identified by the argument.  Currently,
  139.       only KERBEROS_V4 and GSSAPI are defined.
  140.  
  141.       If the server accepts an authentication type with reply code  334,
  142.       then the client must next initiate an authentication exchange (via
  143.       the ADAT command) based on that authentication type.  The goal  of
  144.       the  authentication  exchange is to strongly authenticate the user
  145.       to the server, and to establish a security context [3] under which
  146.       protection of the control and data channels may be performed.
  147.  
  148.       If the server replies with a 234  code,  then  the  authentication
  149.       type  is  accepted,  and  no  ADAT commands are required.  This is
  150.       useful to indicate to the server that the password to be sent in a
  151.       subsequent  PASS  command  is  to  be interpreted differently than
  152.       normal, as in the case of  smart  cards  or  other  non-disclosing
  153.       password   systems.   Challenge  information  intended  for  human
  154.       interpretation may be contained in the  reply.   Such  information
  155.       may also be conveyed in the text of the reply to the USER command.
  156.  
  157.       If the server rejects a type (reply code 504), or any ADAT command
  158.       fails,  then  the  client  may  try another authentication type by
  159.       issuing another AUTH command, or may continue by sending USER  and
  160.       PASS  commands.   Thus,  the  client should request authentication
  161.       types in decreasing order of  preference  (i.e.,  strength).   The
  162.       server  will  reject  (with  a  503  reply  code) any AUTH or ADAT
  163.       commands  sent  after  an  authentication  protocol   successfully
  164.       completes.
  165.  
  166.       The client should not require  the  server  to  support  the  AUTH
  167.       command  or  any  particular  authentication  type.  If either the
  168.       server does not support the AUTH command (reply code 500), or  the
  169.       client  and  server  cannot agree on an authentication type, or no
  170.  
  171.  
  172.  
  173. Expires: January 31, 1994                                       [Page 3]
  174.  
  175. Internet-Draft          FTP Security Extensions                July 1993
  176.  
  177.  
  178.       authentication exchange succeeds, then the default USER  and  PASS
  179.       commands must be performed.
  180.  
  181.       The AUTH command will normally be the first command transmitted by
  182.       the  user after the control connections are made, generally before
  183.       the USER command.   However,  some  authentication  protocols  may
  184.       require  prior  knowledge  of  the  remote  user  name (e.g., some
  185.       challenge/response systems).  In this case, the USER  command  may
  186.       be sent in advance of the AUTH command.
  187.  
  188.       Some servers will require that authentication be performed  before
  189.       certain commands (including USER) will be accepted.  In this case,
  190.       a 530  reply  will  be  sent  indicating  that  an  authentication
  191.       exchange is required.
  192.  
  193.  
  194.    AUTHENTICATION DATA (ADAT)
  195.  
  196.       The argument field is a  Telnet  string  representing  a  base  64
  197.       encoded  authentication  data (see Section 5, "Base 64 Encoding").
  198.       The data is specific to the authentication protocol specified by a
  199.       previous  AUTH  command.   The  ADAT  command,  and the associated
  200.       replies, allow the client  and  server  to  conduct  an  arbitrary
  201.       authentication protocol.  The client will send authentication data
  202.       to the server via the ADAT  command,  and  the  server  will  send
  203.       authentication  back  to  the client by including "ADAT=string" in
  204.       the reply, where string is also a Telnet string representing  base
  205.       64  encoded authentication data.  The server will reply 501 if the
  206.       string could not be base 64 decoded.
  207.  
  208.       If the server sends a 535  reply,  then  the  authentication  data
  209.       could  not  be successfully processed, and the client has not been
  210.       authenticated.  The client may either try  another  authentication
  211.       type  by  sending  another AUTH command, or may send USER and PASS
  212.       commands.  The server will  reply  503  if  no  AUTH  command  was
  213.       previously accepted.
  214.  
  215.       If the server sends a 335 reply, then the authentication data  was
  216.       successfully  processed, but more authentication data is necessary
  217.       to complete the authentication process.  In this case, the  server
  218.       must include encoded authentication data in the reply.  The client
  219.       must process this  returned  data  and  then  issue  another  ADAT
  220.       command.
  221.  
  222.       If the server sends a  235  reply,  optionally  including  encoded
  223.       authentication   data,   then  the  server  considers  the  client
  224.       authenticated.  The client must process  any  authentication  data
  225.       present in the reply.
  226.  
  227.       Appendix I defines the actual protocol for KERBEROS_V4.   Appendix
  228.  
  229.  
  230.  
  231. Expires: January 31, 1994                                       [Page 4]
  232.  
  233. Internet-Draft          FTP Security Extensions                July 1993
  234.  
  235.  
  236.       II defines the actual protocol for GSSAPI.
  237.  
  238.       If an authentication exchange succeeds, then the client's identity
  239.       has  been  authenticated  but not yet authorized.  The client must
  240.       next invoke the USER command to identify to the server the account
  241.       (file  system) for which access is requested.  If the USER command
  242.       results in a 231 reply, then the  client  is  authorized,  and  no
  243.       password is required.  However, the client must then send the PASS
  244.       command to actually log  the  user  in  (the  actual  password  is
  245.       ignored and should be a dummy value).  If the USER command results
  246.       in a 333 reply,  then  the  user  was  not  authorized  without  a
  247.       password,  and  a password must be sent with the PASS command.  In
  248.       this case,  it  is  recommended  that  the  PASS  command  be  ENC
  249.       protected.   Additional  USER  or  PASS commands may be sent after
  250.       success of an ADAT command.
  251.  
  252.       Once the client is successfully authenticated via  AUTH  and  ADAT
  253.       commands,  the rest of the data over the control channel (commands
  254.       and replies) must  be  protected,  either  with  integrity  (by  a
  255.       cryptographic   checksum)   via   the   MIC   command,   or   with
  256.       confidentiality (by encryption) via the ENC  command.   (Also  see
  257.       Section  4  on  protected  replies.)  These  two  commands  may be
  258.       arbitrarily intermixed.  It is up to the client to decide which of
  259.       MIC  and  ENC  commands to use, and it is up to the server when to
  260.       accept either.  The server will return a 502 reply  to  any  other
  261.       command.   The  server  will  return  a  500 reply to a MIC or ENC
  262.       command if no ADAT command succeeded.
  263.  
  264.       Commands sent via the  Telnet  out-of-band  signal  must  also  be
  265.       protected.   That  is,  if  the client sends the Telnet "Interrupt
  266.       Process" (IP) signal followed by the Telnet "Synch"  signal,  then
  267.       the  command  sent  to the server immediately afterwards must also
  268.       protected.
  269.  
  270.       A requirement of all specifications for  authentication  exchanges
  271.       based  on  new  authentication  types  is  that they convey to the
  272.       caller whether encryption is supported on the  resultant  security
  273.       context,  since  it is not a requirement that the ENC command, 632
  274.       protected replies, or the Private protection level  be  supported.
  275.       It is also strongly suggested that per message protection services
  276.       supported by each mechanism perform  message  replay  and  out-of-
  277.       sequence  detection,  since  no  provision  for  these services is
  278.       explicitly made within this specification.
  279.  
  280.       Since no explicit provision is made in this specification for  the
  281.       negotiation  of  alternate  mechanisms  for performing per message
  282.       protection services, implementors should instead utilize the token
  283.       exchange for this purpose.
  284.  
  285.  
  286.  
  287.  
  288.  
  289. Expires: January 31, 1994                                       [Page 5]
  290.  
  291. Internet-Draft          FTP Security Extensions                July 1993
  292.  
  293.  
  294.    INTEGRITY PROTECTED COMMAND (MIC)
  295.  
  296.       The argument field is a Telnet string  consisting  of  a  base  64
  297.       encoded  "safe"  message  produced  by an authentication mechanism
  298.       specific message integrity procedure.  The server will decode  the
  299.       received  string,  verify  its  integrity  via  the authentication
  300.       mechanism specific message integrity procedure, and upon  success,
  301.       interpret  the  resultant  string  as  an  FTP command.  The user-
  302.       process need not include the Telnet end-of-line  code  within  the
  303.       encoded command.
  304.  
  305.       The server will return a 501 reply if the argument  could  not  be
  306.       properly base 64 decoded.
  307.  
  308.       The server will return a 535 reply to any MIC command which  fails
  309.       checksum, replay, sequencing, or other applicable security checks.
  310.  
  311.       The server may return a 402 reply to a MIC command if  it  is  not
  312.       willing  to  accept  MIC  commands  and  instead  will  accept ENC
  313.       commands only.  In this case, the client should retry the enclosed
  314.       command under ENC protection.
  315.  
  316.       The three replies defined above must themselves be protected.
  317.  
  318.       There are no other direct replies from MIC or  ENC  commands;  the
  319.       resultant FTP command will generate its own replies.
  320.  
  321.       In environments where the native character set is not  ASCII,  the
  322.       client  must  translate  the  encapsulated command to ASCII before
  323.       passing  it  to  the  protection  routine,  and  the  server  must
  324.       translate  the  encapsulated  command from ASCII after passing the
  325.       token to the protection routine.
  326.  
  327.  
  328.    PRIVACY PROTECTED COMMAND (ENC)
  329.  
  330.       The argument field is a Telnet string  consisting  of  a  base  64
  331.       encoded  "private" message produced by an authentication mechanism
  332.       specific  message  confidentiality  procedure.   The  server  will
  333.       decode   the   received   string,   verify   its   integrity   and
  334.       confidentiality via the authentication mechanism specific  message
  335.       confidentiality   procedure,   and  upon  success,  interpret  the
  336.       resultant string as an FTP command.
  337.  
  338.       It is strongly recommended that PASS commands be  sent  under  ENC
  339.       protection, when possible.
  340.  
  341.       The server will return a 501 reply if the argument  could  not  be
  342.       properly base 64 decoded.
  343.  
  344.  
  345.  
  346.  
  347. Expires: January 31, 1994                                       [Page 6]
  348.  
  349. Internet-Draft          FTP Security Extensions                July 1993
  350.  
  351.  
  352.       The server will return a 535 reply to any ENC command which cannot
  353.       be  properly  decrypted, or fails checksum, replay, sequencing, or
  354.       other applicable security checks.
  355.  
  356.       The server will return a 402 reply if it does not support the  ENC
  357.       command.   In  this  case,  the  client  should retry the enclosed
  358.       command under MIC protection.
  359.  
  360.       The three replies defined above must themselves be protected.
  361.  
  362.  
  363.    DATA CHANNEL PROTECTION LEVEL (PROT)
  364.  
  365.       The argument is a single Telnet character code specifying the data
  366.       channel  protection  level.  The PROT command will be rejected and
  367.       the server will reply 504 if no previous ADAT  command  succeeded,
  368.       or the specified protection level is not supported.  Upon success,
  369.       a 200 reply will be sent by the server, indicating  that  the  new
  370.       protection level is now in effect.
  371.  
  372.       The following codes are assigned for protection levels:
  373.  
  374.          C - Clear
  375.          S - Safe
  376.          P - Private
  377.  
  378.       The default protection level is Clear.  The Safe protection  level
  379.       is  required  to  be implemented by all authentication types which
  380.       exchange ADAT  commands,  but  the  Private  protection  level  is
  381.       optional.
  382.  
  383.       When using the Safe protection level, all data sent over the  data
  384.       channel  is  to  be integrity protected by cryptographic checksum.
  385.       When using the Private protection level, all data  sent  over  the
  386.       data channel is to be privacy protected by encryption.
  387.  
  388.       The  sender  will  apply  protection  services  after   all   data
  389.       transformations  associated  with the current representation type,
  390.       file structure, and transfer mode have been performed.   The  data
  391.       sent   over  the  data  channel  is,  for  the  purposes  of  data
  392.       protection, to be treated as a  byte  stream.   An  authentication
  393.       mechanism  specific  data protection procedure will be employed by
  394.       the sender to protect this  byte  stream.   The  procedure  should
  395.       process  a  buffer  of  bytes  at a time, and send the result as a
  396.       stream of bytes, prepending each transferred  buffer  with  a  two
  397.       byte  length field (most significant byte first).  Thus, a minimal
  398.       implementation must be able to handle a buffer  length  of  65,536
  399.       bytes.   (Implementors  must  ensure  that  they encrypt a maximum
  400.       cleartext  buffer  somewhat  smaller  than  this  such  that   the
  401.       resultant  ciphertext buffer is assured to be no greater than this
  402.  
  403.  
  404.  
  405. Expires: January 31, 1994                                       [Page 7]
  406.  
  407. Internet-Draft          FTP Security Extensions                July 1993
  408.  
  409.  
  410.       maximum.) The receiver will read the two byte  length  field,  and
  411.       then  read  that  number  of  bytes of protected data, passing the
  412.       buffer to an authentication  mechanism  specific  data  protection
  413.       procedure.   Further  buffers will be similarly read and processed
  414.       until all bytes are sent.  Any transformations associated with the
  415.       current  representation  type,  file  structure, and transfer mode
  416.       would then be performed by the receiver  on  the  resultant  data.
  417.       When  using  block  transfer mode, the sender's (cleartext) buffer
  418.       size is independent of the block size.
  419.  
  420.       Under the Clear protection level (i.e., as  currently  defined  in
  421.       RFC  959),  and  when  in stream mode, the sender indicates end of
  422.       file  by  closing  the  data  connection.   This   is   inherently
  423.       unreliable,  since  the  receiver  cannot  determine  whether  the
  424.       connection was closed prematurely.  Transferring files  under  the
  425.       Safe  or  Private  protection  level allows the sender to convey a
  426.       positive indication of end of file by sending a  protected  buffer
  427.       which contains zero bytes of cleartext data.  Upon receipt of such
  428.       a zero length cleartext buffer, the  recipient  should  close  the
  429.       data  connection (without further reading from the connection) and
  430.       consider the file transfer complete.  If the connection is  closed
  431.       before such a buffer is received, then the file transfer should be
  432.       aborted, and the user should be alerted.  If the  server  was  the
  433.       recipient, then it should send a 535 reply in this case.
  434.  
  435.       If any data protection services  fail  at  any  time  during  data
  436.       transfer at the server end, the server will send a 535 reply.
  437.  
  438.       The server will reply 534 to a STOR, STOU, RETR,  LIST,  NLST,  or
  439.       APPE  command  if the current protection level is not at the level
  440.       dictated by the server's security requirements for the  particular
  441.       file transfer.
  442.  
  443.  
  444. 4. New FTP Replies
  445.  
  446.    All replies after a successful ADAT command must be protected.  A new
  447.    reply type is introduced for this purpose, indicated by a sixth value
  448.    for the first digit of the reply code:
  449.  
  450.    6yz   Protected reply
  451.  
  452.       The text of this reply is to be decoded and interpreted as an  FTP
  453.       reply (if such decoding is successful).  If the reply code is 631,
  454.       then the text of the reply is  integrity  protected  in  the  same
  455.       manner  as  MIC commands.  If the reply code is 632, then the text
  456.       of the reply is privacy  protected  in  the  same  manner  as  ENC
  457.       commands.  The server need not include the Telnet end-of-line code
  458.       within the encoded reply.  All replies must be protected  once  an
  459.       ADAT command succeeds.  The server may send a protected reply only
  460.  
  461.  
  462.  
  463. Expires: January 31, 1994                                       [Page 8]
  464.  
  465. Internet-Draft          FTP Security Extensions                July 1993
  466.  
  467.  
  468.       if a previous ADAT command succeeded.
  469.  
  470.       The security policy of the server will dictate  when  631  or  632
  471.       replies are to be used.  As a general rule, the server should send
  472.       a 631 reply to a MIC command, and a 632 reply to an  ENC  command.
  473.       The  server  must  not  send  632  replies  if the client does not
  474.       support encryption (this  should  be  indicated  by  the  security
  475.       context).  If, upon context establishment, it is not known whether
  476.       the client supports encryption, then the server  may  send  a  632
  477.       reply  only  if  client  support  of encryption has been indicated
  478.       implicitly by means of the client issuing an ENC command or a PROT
  479.       P command.
  480.  
  481.       Multi-line replies are handled as follows.  If the server sends  a
  482.       protected  reply  in  which  the  decoded reply has a hyphen ("-")
  483.       immediately following the reply code, then the  server  will  send
  484.       the  rest  of  the  lines  of  text  of  the multi-line reply each
  485.       protected and base 64 encoded as was  the  first  line,  and  each
  486.       followed  by  the  Telnet  end-of-line code.  The last line of the
  487.       multi-line reply will be that  line  which  when  decoded  by  the
  488.       receiver  begins  with the initial reply code followed by a space.
  489.       For consistency with RFC 959 replies, each  line  of  a  protected
  490.       multi-line  replies  should  begin  with  either a 631 or 632 code
  491.       followed by a hyphen or, on the last line, a space.  However, note
  492.       that  it is the format of the decoded reply, and not the enclosing
  493.       protected reply, that indicates a multi-line reply.
  494.  
  495.       The following is an example showing the  format  of  a  four  line
  496.       multi-line reply:
  497.  
  498.               631-<base64string>
  499.               631-<base64string>
  500.               631-<base64string>
  501.               631 <base64string>
  502.  
  503.       If the server for some reason cannot encode the  reply,  then  the
  504.       unprotected  reply  will  be  sent  instead.   However, the client
  505.       should ignore the reply code of any cleartext reply sent after the
  506.       success of an ADAT command, and instead simply display the text of
  507.       the reply to the user.
  508.  
  509.  
  510. 5. Base 64 Encoding
  511.  
  512.    Base 64 encoding is the same as the Printable Encoding  described  in
  513.    Section 4.3.2.4 of [2] and is defined as follows.
  514.  
  515.    Proceeding from left to right, the  bit  string  resulting  from  the
  516.    mechanism  specific  protection  routine  is  encoded into characters
  517.    which  are  universally  representable  at  all  sites,  though   not
  518.  
  519.  
  520.  
  521. Expires: January 31, 1994                                       [Page 9]
  522.  
  523. Internet-Draft          FTP Security Extensions                July 1993
  524.  
  525.  
  526.    necessarily  with the same bit patterns (e.g., although the character
  527.    "E" is represented in an ASCII-based system as hexadecimal 45 and  as
  528.    hexadecimal  C5  in an EBCDIC-based system, the local significance of
  529.    the two representations is equivalent).
  530.  
  531.    A 64-character subset of International Alphabet IA5 is used, enabling
  532.    6  bits  to  be  represented  per printable character.  (The proposed
  533.    subset of characters is represented identically in  IA5  and  ASCII.)
  534.    The  character  "="  signifies a special processing function used for
  535.    padding within the printable encoding procedure.
  536.  
  537.    The encoding process represents 24-bit groups of input bits as output
  538.    strings  of  4  encoded  characters.   Proceeding  from left to right
  539.    across a 24-bit input group output from the authentication  mechanism
  540.    specific message protection procedure, each 6-bit group is used as an
  541.    index into an array of  64  printable  characters,  namely  "[A-Z][a-
  542.    z][0-9]+/".   The  character referenced by the index is placed in the
  543.    output string.  These characters are selected so as to be universally
  544.    representable,  and  the  set  excludes  characters  with  particular
  545.    significance to Telnet (e.g., "<CR>", "<LF>", IAC).
  546.  
  547.    Special processing is performed if fewer than 24 bits  are  available
  548.    in  an  input group at the end of a message.  A full encoding quantum
  549.    is always completed at the end of a  message.   When  fewer  than  24
  550.    input  bits  are available in an input group, zero bits are added (on
  551.    the right) to form  an  integral  number  of  6-bit  groups.   Output
  552.    character  positions which are not required to represent actual input
  553.    data are set to the character "=".   Since  all  canonically  encoded
  554.    output  is an integral number of octets, only the following cases can
  555.    arise: (1) the  final  quantum  of  encoding  input  is  an  integral
  556.    multiple  of  24 bits; here, the final unit of encoded output will be
  557.    an integral multiple of 4 characters with no  "="  padding,  (2)  the
  558.    final  quantum  of  encoding input is exactly 8 bits; here, the final
  559.    unit of encoded output will be two characters  followed  by  two  "="
  560.    padding  characters,  or  (3)  the final quantum of encoding input is
  561.    exactly 16 bits; here, the final unit of encoded output will be three
  562.    characters followed by one "=" padding character.
  563.  
  564.    Implementors should keep in mind that the base 64 encodings in  ADAT,
  565.    MIC, and ENC commands, and in 631 and 632 replies, may be arbitrarily
  566.    long.  Thus, the entire line must be read before it can be processed.
  567.    Several successive reads on the control channel may be necessary.  It
  568.    is not appropriate to for a server to reject a command  containing  a
  569.    base  64  encoding  simply  because it is too long (assuming that the
  570.    decoding is otherwise well formed in the  context  in  which  it  was
  571.    sent).
  572.  
  573.    Case  should  not  be  ignored  when  reading  commands  and  replies
  574.    containing base 64 encodings.
  575.  
  576.  
  577.  
  578.  
  579. Expires: January 31, 1994                                      [Page 10]
  580.  
  581. Internet-Draft          FTP Security Extensions                July 1993
  582.  
  583.  
  584. 6. Command Summary
  585.  
  586.    The following is a summary of the commands described above:
  587.  
  588.       AUTH <SP> <auth-type> <CRLF>
  589.       ADAT <SP> <base64string> <CRLF>
  590.       MIC  <SP> <base64string> <CRLF>
  591.       ENC  <SP> <base64string> <CRLF>
  592.       PROT <SP> <protection-level> <CRLF>
  593.  
  594.       The syntax of the above argument fields (using BNF notation where
  595.       applicable) is:
  596.  
  597.       <auth-type> ::= <string>
  598.       <string>    ::= <char> | <char><string>
  599.       <char>      ::= any of the 128 ASCII characters except <CR> and <LF>
  600.       <protection-level> ::= C | S | P
  601.       <base64string> ::= <quads> | <quads><terminal>
  602.       <quads> ::= <quad> | <quad><quads>
  603.       <quad> ::= <base64char><base64char><base64char><base64char>
  604.       <base64char> ::= ASCII A through Z
  605.                      | ASCII a through z
  606.                      | ASCII 0 through 9
  607.                      | ASCII +
  608.                      | ASCII /
  609.       <terminal>  ::= <base64char><terminal1><pad><pad>
  610.                     | <base64char><base64char><terminal2><pad>
  611.       <terminal1> ::= A | Q | g | w
  612.       <terminal2> ::= A | E | I | M | Q | U | Y | c |
  613.                       g | k | o | s | w | 0 | 4 | 8
  614.       <pad>       ::= ASCII =
  615.  
  616.  
  617.    The following lists the various reply codes for each new command:
  618.  
  619.    AUTH
  620.       234
  621.       334
  622.       500, 501, 503, 504, 421
  623.    ADAT
  624.       235
  625.       335
  626.       500, 501, 503, 535, 421
  627.    MIC
  628.       402
  629.       500, 501, 535, 421
  630.    ENC
  631.       402
  632.       500, 501, 535, 421
  633.    PROT
  634.  
  635.  
  636.  
  637. Expires: January 31, 1994                                      [Page 11]
  638.  
  639. Internet-Draft          FTP Security Extensions                July 1993
  640.  
  641.  
  642.       200
  643.       500, 501, 504, 421, 530
  644.  
  645.    The following are additional reply codes for existing  commands  (502
  646.    is  the  only  reply for all commands except ENC and MIC once an ADAT
  647.    command succeeds):
  648.  
  649.    USER
  650.       231
  651.       333
  652.    STOR
  653.       534, 535
  654.    STOU
  655.       534, 535
  656.    RETR
  657.       534, 535
  658.    LIST
  659.       534, 535
  660.    NLST
  661.       534, 535
  662.    APPE
  663.       534, 535
  664.  
  665.    The following is the syntax for protected replies:
  666.  
  667.    <code> <SP> <base64string> <CRLF>
  668.    <code> ::= 631 | 632
  669.  
  670.    Lines of the following form may preceed this in the case of a  multi-
  671.    line protected reply:
  672.  
  673.    <code> <hyphen> <base64string> <CRLF>
  674.    <hyphen> ::= ASCII -
  675.  
  676. 7. References
  677.  
  678.   [1] Reynolds, Joyce, and Postel, Jon, "File Transfer Protocol  (FTP)",
  679.       RFC 959, ISI, October 1985.
  680.  
  681.   [2] Linn, John, "Privacy Enhancement  for  Internet  Electronic  Mail:
  682.       Part  I:  Message  Encryption  and Authentication Procedures", RFC
  683.       1421, February 1993.
  684.  
  685.   [3] Linn, John, "Generic  Security  Service  API  (GSSAPI)",  Internet
  686.       Draft, November 1992.
  687.  
  688.   [4] Braden, R., "Requirements for Internet Hosts  --  Application  and
  689.       Support", RFC 1123, October 1989.
  690.  
  691.   [5]  Borman,  D.,  "Telnet  Authentication  and  Encryption   Option",
  692.  
  693.  
  694.  
  695. Expires: January 31, 1994                                      [Page 12]
  696.  
  697. Internet-Draft          FTP Security Extensions                July 1993
  698.  
  699.  
  700.       Internet Draft, Cray Research, Inc, April 1993.
  701.  
  702. Security Considerations
  703.  
  704.    Third party file transfers cannot be secured using these  extensions,
  705.    since  a  security  context cannot be established between two servers
  706.    using these facilities (no control connection exists  between  server
  707.    over  which  to  pass  ADAT  tokens).   Further  work in this area is
  708.    deferred.
  709.  
  710. APPENDIX I:  SPECIFICATION UNDER KERBEROS VERSION 4
  711.  
  712.    The authentication  type  (for  the  AUTH  command)  associated  with
  713.    Kerberos   Version   4   is  KERBEROS_V4.   If  the  server  supports
  714.    KERBEROS_V4, it will respond with a 334 reply code indicating that an
  715.    ADAT command is expected next.
  716.  
  717.    The client should  retrieve  a  ticket  for  the  Kerberos  principal
  718.    "ftp.hostname@realm"  by  calling krb_mk_req(3) with a principal name
  719.    of "ftp", an instance equal to the canonical host name of the  server
  720.    with all letters in lower case (as returned by krb_get_phost(3)), the
  721.    server's realm name  (as  returned  by  krb_realmofhost(3)),  and  an
  722.    arbitrary checksum.  The ticket must then be base 64 encoded and sent
  723.    as the argument to an ADAT command.
  724.  
  725.    The server must base 64 decode the argument to the ADAT  command  and
  726.    pass  the  result  to  krb_rd_req(3).  The server must add one to the
  727.    checksum from the authenticator and  sign  it  using  krb_mk_safe(3),
  728.    then  base 64 encode the result.  Upon success, the server must reply
  729.    to the client with a 235 code and include "ADAT=base64string" in  the
  730.    text of the reply.  Upon failure, the server will reply 535.
  731.  
  732.    Upon receipt of the 235 reply from the server, the client must  parse
  733.    the  text  of  the reply for the base 64 encoded data, decode it, and
  734.    pass the result to krb_rd_safe(3).  The client  should  consider  the
  735.    server  authenticated  if the resultant checksum is equal to one plus
  736.    the value previously sent.
  737.  
  738.    The procedure  associated  with  integrity  protected  MIC  commands,
  739.    replies, and Safe file transfers is:
  740.  
  741.       krb_mk_safe(3) for the sender
  742.       krb_rd_safe(3) for the receiver
  743.  
  744.    The  procedure  associated  with  privacy  protected  ENC   commands,
  745.    replies, and Private file transfers is:
  746.  
  747.       krb_mk_priv(3) for the sender
  748.       krb_rd_priv(3) for the receiver
  749.  
  750.  
  751.  
  752.  
  753. Expires: January 31, 1994                                      [Page 13]
  754.  
  755. Internet-Draft          FTP Security Extensions                July 1993
  756.  
  757.  
  758.    Note that this specification for KERBEROS_V4  contains  no  provision
  759.    for  negotiating  alternate  means  for integrity and confidentiality
  760.    routines.  Note also that the ADAT exchange does not  convey  whether
  761.    the peer supports confidentiality services.
  762.  
  763. APPENDIX II: SPECIFICATION UNDER THE GSSAPI
  764.  
  765.    The authentication type (for the AUTH command)  associated  with  all
  766.    mechanisms employing the GSSAPI is GSSAPI.  If the server supports an
  767.    authentication mechanism employing the GSSAPI, it will respond with a
  768.    334 reply code indicating that an ADAT command is expected next.
  769.  
  770.    The client  should  begin  the  authentication  exchange  by  calling
  771.    GSS_Init_Sec_Context, passing in NULL for claimant_cred_handle to get
  772.    the default credentials for the user (this is to  avoid  dependencies
  773.    on  names  for  particular  mechanisms),  0  for input_context_handle
  774.    (initially), NULL for mech_type (indicating  "use  default  mechanism
  775.    type"),  and  a  targ_name  equal to output_name from GSS_Import_Name
  776.    called  with  input_name_type  of  NULL  and   input_name_string   of
  777.    "SERVICE:ftp@hostname"  where  "hostname" is the fully qualified host
  778.    name of the server with all letters in lower case.  The  output_token
  779.    must  then  be base 64 encoded and sent to the server as the argument
  780.    to   an    ADAT    command.     If    GSS_Init_Sec_Context    returns
  781.    GSS_CONTINUE_NEEDED,  then  the  client  should  expect a token to be
  782.    returned in the  reply  to  the  ADAT  command.   This  token  should
  783.    subsequently  be  passed to another call to GSS_Init_Sec_Context.  In
  784.    this case, if GSS_Init_Sec_Context returns no output_token, then  the
  785.    reply  code from the server for the previous ADAT command should have
  786.    been 235.  If  GSS_Init_Sec_Context  returns  GSS_COMPLETE,  then  no
  787.    further  tokens  should  be  expected from the server, and the client
  788.    should consider the server authenticated.
  789.  
  790.    The server must base 64 decode the argument to the ADAT  command  and
  791.    pass  the  resultant  token to GSS_Accept_Sec_Context as input_token,
  792.    setting acceptor_cred_handle to NULL (for "use default credentials"),
  793.    and  0  for  input_context_handle (initially).  If an output_token is
  794.    returned, it should be base 64 encoded and returned to the client  by
  795.    including   "ADAT=base64string"   in  the  text  of  the  reply.   If
  796.    GSS_Accept_Sec_Context returns GSS_COMPLETE, the reply code should be
  797.    235,  and  the  server  should consider the client authenticated.  If
  798.    GSS_Accept_Sec_Context returns GSS_CONTINUE_NEEDED,  the  reply  code
  799.    should be 335.  Otherwise, the reply code should be 535, and the text
  800.    of the reply should contain a descriptive error message.
  801.  
  802.    The procedure  associated  with  integrity  protected  MIC  commands,
  803.    replies, and Safe file transfers is:
  804.  
  805.       GSS_Safe for the sender
  806.       GSS_Verify for the receiver
  807.  
  808.  
  809.  
  810.  
  811. Expires: January 31, 1994                                      [Page 14]
  812.  
  813. Internet-Draft          FTP Security Extensions                July 1993
  814.  
  815.  
  816.    The  procedure  associated  with  privacy  protected  ENC   commands,
  817.    replies, and Private file transfers is:
  818.  
  819.       GSS_Seal for the sender
  820.       GSS_Unseal for the receiver
  821.  
  822.    Both the client and server should inspect the value of conf_avail  to
  823.    determine whether the peer supports confidentiality services.
  824.  
  825. Author's Address:
  826.  
  827.    Steven J. Lunt
  828.    Bellcore
  829.    RRC-1L213
  830.    444 Hoes Lane
  831.    Piscataway, NJ 08854
  832.  
  833.    Phone: (908) 699-4244
  834.    EMail: lunt@bellcore.com
  835.  
  836.    Mailing List: ftp-wg@tgv.com
  837.  
  838. Chair's Address:
  839.  
  840.    The working group can be contacted via the current chair:
  841.  
  842.    Sam Sjogren
  843.    TGV, Inc.
  844.    603 Mission St.
  845.    Santa Cruz, CA  95060
  846.  
  847.    Phone: (408) 427-4366
  848.    EMail: sjogren@tgv.com
  849.  
  850. Author's Notes:
  851.  
  852.    This is implemented and working for Kerberos V4 on SunOS 4.1.2  using
  853.    SunOS  source  for ftp and ftpd, and also the BSD Reno source for ftp
  854.    and ftpd.
  855.  
  856.    YET TO BE DONE:
  857.  
  858.  
  859.      1.  Determine a suitably general targ_name for GSSAPI.
  860.  
  861.      2.  Implementation using GSSAPI.
  862.  
  863.      3.  The client may fail when processing the ADAT data  from  a  235
  864.          reply,  in  which case the server thinks things are OK, but the
  865.          client thinks otherwise.  Unclear how to proceed at that point,
  866.  
  867.  
  868.  
  869. Expires: January 31, 1994                                      [Page 15]
  870.  
  871. Internet-Draft          FTP Security Extensions                July 1993
  872.  
  873.  
  874.          other than to drop the connection.
  875.  
  876.      4.  New state diagrams might need to be drawn  for  how  the  AUTH,
  877.          ADAT, USER, and PASS commands now flow.
  878.  
  879.      5.  It would be desirable to make use  of  the  rcmd  principal  in
  880.          Kerberos  V4,  but there may be some environments where the ftp
  881.          server needs to run in a chroot'ed environment.  Thus, the  ftp
  882.          principal  was specified.  There should be some way to make use
  883.          of the rcmd principal if there  is  no  ftp  principal  at  the
  884.          server site.
  885.  
  886.  
  887.  
  888.  
  889.  
  890.  
  891.  
  892.  
  893.  
  894.  
  895.  
  896.  
  897.  
  898.  
  899.  
  900.  
  901.  
  902.  
  903.  
  904.  
  905.  
  906.  
  907.  
  908.  
  909.  
  910.  
  911.  
  912.  
  913.  
  914.  
  915.  
  916.  
  917.  
  918.  
  919.  
  920.  
  921.  
  922.  
  923.  
  924.  
  925.  
  926.  
  927. Expires: January 31, 1994                                      [Page 16]
  928.  
  929.